package testcase;
 

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import junit.framework.TestCase;
import org.junit.Test;


import static org.junit.Assert.*;

import java.io.*;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;

import org.junit.Test;

import maincode.*;
import junit.framework.TestCase;
 
//private static final double DELTA = 1e-15;
public class DataOfDateTest extends TestCase{
	@Test 
	//Test whether can get data from website successfully
	public void test1(){
	
		//USD 2014-11-07 http://currencies.apps.grandtrunk.net/getrate/2014-11-07/usd/hkd
		double result = dataOfDate.getDataAtDate(16381,0);
		assertEquals(7.75332849189,result,0.000000000001);
	}
	
	@Test
	public void test2(){
		//http://currencies.apps.grandtrunk.net/getrate/2014-11-07/cny/hkd
		double result = dataOfDate.getDataAtDate(16381,1);
		assertEquals(1.26636881227,result,0.000000000001);		
	}

	@Test
	public void test3(){
		//http://currencies.apps.grandtrunk.net/getrate/2014-11-07/jpy/hkd
		double result = dataOfDate.getDataAtDate(16381,2);
		assertEquals(0.0672454335503,result,0.000000000001);		
	}

	@Test
	public void test4(){
		//http://currencies.apps.grandtrunk.net/getrate/2014-11-07/eur/hkd
		double result = dataOfDate.getDataAtDate(16381,3);
		assertEquals(9.6087,result,0.000000000001);		
	}

	@Test
	public void test5(){
		//http://currencies.apps.grandtrunk.net/getrate/2014-11-07/aud/hkd
		double result = dataOfDate.getDataAtDate(16381,4);
		assertEquals(6.66437786101,result,0.000000000001);		
	}

	@Test
	public void test6(){
		//http://currencies.apps.grandtrunk.net/getrate/2014-11-07/gbp/hkd
		double result = dataOfDate.getDataAtDate(16381,5);
		assertEquals(12.2653816696,result,0.000000000001);		
	}
		
}
